package oa.hleast.xswl.common.config;

import com.baidu.aip.speech.AipSpeech;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author 302
 */
@Configuration
@Slf4j
@AllArgsConstructor
public class ThirdConfig implements WebMvcConfigurer {

    private final AppProps appProps;

    @Bean
    public AipSpeech baiduAipClient() {


        log.info("baiduappid ={}", appProps.getBaiduAiAppId());
        log.info("baiduappkey ={}", appProps.getBaiduAiAppKey());
        log.info("baiduappsecrekey = {}", appProps.getBaiduAiSecretKey());
        // 初始化一个AipSpeech
        AipSpeech client = new AipSpeech(appProps.getBaiduAiAppId(), appProps.getBaiduAiAppKey(), appProps.getBaiduAiSecretKey());

        // 可选：设置网络连接参数
        client.setConnectionTimeoutInMillis(2000);
        client.setSocketTimeoutInMillis(60000);

        // 可选：设置代理服务器地址, http和socket二选一，或者均不设置
//        client.setHttpProxy("proxy_host", proxy_port);  // 设置http代理
//        client.setSocketProxy("proxy_host", proxy_port);  // 设置socket代理

        // 可选：设置log4j日志输出格式，若不设置，则使用默认配置
        // 也可以直接通过jvm启动参数设置此环境变量
        System.setProperty("aip.log4j.conf", "path/to/your/log4j.properties");

        return client;
    }
}
